/* This reference code does not compile with the project. */

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace WSPBuilder_LoggedComments {
  public class LoggedCommentsFieldFieldEditor : UserControl, IFieldEditor {
    // Fields
    protected DropDownList DdlLookupFieldTargetList;
    private LoggedCommentsField fldLoggedCommentsField;
    protected Label LabelLookupFieldTargetListTitle;

    public void InitializeWithField(SPField field) {
      this.fldLoggedCommentsField = field as LoggedCommentsField;

      if (this.Page.IsPostBack) {
        return;
      }

      DdlLookupFieldTargetList.Items.Clear();

      DdlLookupFieldTargetList.Items.Add("One");
      DdlLookupFieldTargetList.Items.Add("Two");
      DdlLookupFieldTargetList.Items.Add("Default Value");
      DdlLookupFieldTargetList.Items.Add("Four");


      if (field != null) {
        DdlLookupFieldTargetList.SelectedValue = fldLoggedCommentsField.MyCustomProperty;
        this.DdlLookupFieldTargetList.Visible = true;
      } else {
        DdlLookupFieldTargetList.SelectedValue = "Default Value";
        this.DdlLookupFieldTargetList.Visible = true;
      }
    }

    public void OnSaveChange(SPField field, bool bNewField) {
      LoggedCommentsField lookup = (LoggedCommentsField)field;

      lookup.IsNew = bNewField;
      lookup.MyCustomProperty = this.DdlLookupFieldTargetList.SelectedValue;

    }


    // Properties
    public bool DisplayAsNewSection {
      get {
        return false;
      }
    }



  }

}